'use strict'
/* @ngInject */
function httpInterceptor($q, $location) {
    return {
        request: function (config) {
            config.timeout = 300000;
            return config;
        },
        responseError: function (response) {

            //服务器端验证，如果没有登录，返回登陆页面
            if (response.status === 401) {
                $location.path('/login');
            } else if (response.status === 500) {
                //alert('服务器错误！');
            }
            return $q.reject(response);
        }
    };
}
function Config($httpProvider, $logProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/login');
    $logProvider.debugEnabled(true);
    // $httpProvider.defaults.useXDomain = true;
    // $httpProvider.defaults.withCredentials = true;
    $httpProvider
        .interceptors
        .push('httpInterceptor');
}
angular
    .module('root', ['ui.router', 'templates', 'yky.components','imageViewer'])
    .factory('httpInterceptor', httpInterceptor)
    .config(Config)
    .constant('HOST', 'http://localhost:9000/')
    .constant('API', 'http://localhost:9000/api/')
